package main

import (
	"fmt"
	"reflect"
	"unsafe"
)

type Gaga interface {
	shout() string
}

type Run interface {
	run() int
}

// 预先设定, 会跑, 会叫的都是鸭子
type Duck interface {
	Gaga
	Run
}

type Goods interface {
	price() float32
	category() string
}

func eat(duck Duck) {
	// 有那么一点残忍, 为啥要吃这个鸭子
	sizeof := unsafe.Sizeof(duck)
	fmt.Println(sizeof)
	fmt.Printf("duck address %p, duck type: %s\n", &duck, reflect.TypeOf(duck))
	fmt.Printf("I'm eating a duck which shout like %s, run with speed %d \n ", duck.shout(), duck.run())
}

type Car struct {
	name string
}

func (c Car) price() float32 {
	return 1200000000
}

func (c Car) category() string {
	return "high"
}

func (c Car) shout() string {
	return "di di di ~~"
}

func (c Car) run() int {
	return 2020
}

func main() {

	car := Car{name: "Benz"}
	carSize := unsafe.Alignof(car)
	fmt.Println(carSize)
	fmt.Printf("car address: %p\n", &car)
	eat(car)
}
